import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSControlAction } from '../ipscontrol-action';
import { PSAjaxControlContainerImpl } from '../psajax-control-container-impl';
import { IPSDEEditForm } from '../form/ipsdeedit-form';
import { IPSDEWizardPanel } from './ipsdewizard-panel';
import { IPSDEWizard } from '../../dataentity/wizard/ipsdewizard';

export class PSDEWizardPanelImpl extends PSAjaxControlContainerImpl implements IPSDEWizardPanel {
  get codeName(): string {
    return this.M.codeName;
  }

  protected finishpscontrolaction: IPSControlAction | null = null;

  getFinishPSControlAction(): IPSControlAction | null {
    if (this.finishpscontrolaction != null) return this.finishpscontrolaction;
    const value = this.M.getFinishPSControlAction;
    if (value == null) {
      return null;
    }
    this.finishpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.finishpscontrolaction;
  }

  get finishPSControlAction(): IPSControlAction | null {
    return this.getFinishPSControlAction();
  }

  getFinishPSControlActionMust(): IPSControlAction {
    const value = this.getFinishPSControlAction();
    if (value == null) {
      throw new Error('未指定完成行为');
    }
    return value;
  }

  protected initpscontrolaction: IPSControlAction | null = null;

  getInitPSControlAction(): IPSControlAction | null {
    if (this.initpscontrolaction != null) return this.initpscontrolaction;
    const value = this.M.getInitPSControlAction;
    if (value == null) {
      return null;
    }
    this.initpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.initpscontrolaction;
  }

  get initPSControlAction(): IPSControlAction | null {
    return this.getInitPSControlAction();
  }

  getInitPSControlActionMust(): IPSControlAction {
    const value = this.getInitPSControlAction();
    if (value == null) {
      throw new Error('未指定初始化行为');
    }
    return value;
  }

  protected psdeeditforms: IPSDEEditForm[] | null = null;

  getPSDEEditForms(): IPSDEEditForm[] | null {
    if (this.psdeeditforms == null) {
      this.psdeeditforms = this.fillChildListModel(this.M.getPSDEEditForms, 'control.form.IPSDEEditForm') as IPSDEEditForm[];
    }
    return this.psdeeditforms;
  }

  get psDEEditForms(): IPSDEEditForm[] | null {
    return this.getPSDEEditForms();
  }

  findPSDEEditForm(objKey: any): IPSDEEditForm | null {
    return this.getPSModel5('control.form.IPSDEEditForm', this.getPSDEEditForms(), objKey) as IPSDEEditForm;
  }

  protected psdewizard: IPSDEWizard | null = null;

  getPSDEWizard(): IPSDEWizard | null {
    if (this.psdewizard != null) return this.psdewizard;
    const value = this.M.getPSDEWizard;
    if (value == null) {
      return null;
    }
    this.psdewizard = this.getPSModel4('dataentity.wizard.IPSDEWizard', value, 'getPSDEWizard') as IPSDEWizard;
    return this.psdewizard;
  }

  get psDEWizard(): IPSDEWizard | null {
    return this.getPSDEWizard();
  }

  getPSDEWizardMust(): IPSDEWizard {
    const value = this.getPSDEWizard();
    if (value == null) {
      throw new Error('未指定实体向导对象');
    }
    return value;
  }

  protected statepsappdefield: IPSAppDEField | null = null;

  getStatePSAppDEField(): IPSAppDEField | null {
    if (this.statepsappdefield != null) return this.statepsappdefield;
    const value = this.M.getStatePSAppDEField;
    if (value == null) {
      return null;
    }
    this.statepsappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getStatePSAppDEField') as IPSAppDEField;
    return this.statepsappdefield;
  }

  get statePSAppDEField(): IPSAppDEField | null {
    return this.getStatePSAppDEField();
  }

  getStatePSAppDEFieldMust(): IPSAppDEField {
    const value = this.getStatePSAppDEField();
    if (value == null) {
      throw new Error('未指定状态应用实体属性');
    }
    return value;
  }

  get wizardStyle(): string {
    return this.M.wizardStyle;
  }

  get showActionBar(): boolean {
    return this.M.showActionBar;
  }

  get showStepBar(): boolean {
    return this.M.showStepBar;
  }

  get cls(): string {
    return 'PSDEWizardPanelImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.wizardpanel.IPSDEWizardPanel' || cls == 'control.wizardpanel.IPSWizardPanel') return true;
    return super.instanceof(cls);
  }
}
